<!-- 绿色通道- 患者列表主界面 -->
<template>
  <div id="box">
    <homePage v-show="homeCheck" ref="homePage" @homePageToFather="filial" />
    <span v-if="!homeCheck">
      <medicalRecords v-if="chestPain_or_Stroke=='胸痛' " :mrdata="checkData" @medicalRecordsToFather="filialBack" />
      <medicalRecordsStroke v-if="chestPain_or_Stroke=='卒中' " :mrdata="checkData" @medicalRecordsStrokeToFather="filialBack" />
      <medicalRecordsTrauma v-if="chestPain_or_Stroke=='创伤' " :mrdata="checkData" @medicalRecordsStrokeToFather="filialBack" />
    </span>
    <!-- 这里使用v-if 每次重新加载页面, 保证传值无缓存 -->
  </div>
</template>
<script>
// import { parseTime } from "@/utils";
// import Cookies from 'js-cookie'
// import { getToken, getUserId } from '@/utils/auth'
import homePage from '@/views/green-channel/homePage.vue'
import medicalRecords from '@/views/green-channel/medicalRecords.vue'
import medicalRecordsStroke from '@/views/green-channel/medicalRecordsStroke.vue'
import medicalRecordsTrauma from '@/views/green-channel/medicalRecordsTrauma.vue'
export default {
  name: 'PatientsList',
  components: { homePage, medicalRecords, medicalRecordsStroke, medicalRecordsTrauma },
  data() {
    return {
      homeCheck: true,
      chestPain_or_Stroke: '胸痛',
      checkData: {},
      newPatient: false
    }
  },
  computed: {},
  created() {
    //   console.log('归档设置',this.$route.params.list)
    //   console.log('档案管理',this.$route.params.datalist)
    //   console.log(66969, this.$route)
    // console.log(this.$store.getters.dataBus)
    // console.log(this.$store.getters.consultationsId)
    // 发送信息给服务端
    // this.$socket.emit('connect', {
    //   'loginUserNum': '368'
    // })
    // this.$socket.on('connect', () => {
    //   alert(111)
    // })
    // 接收服务端的信息
    // this.$sockets.subscribe('push_event', (data) => {
    //   console.log('接收服务端的信息', data)
    // })
  },
  mounted() {
    /* dataBus 目前使用于会诊跳转 */
    if (!!this.$store.getters.consultationsId && this.$store.getters.dataBus.dispatchId) { // cid有值 && dastabus有值
      this.checkData = this.$store.getters.dataBus // checkData赋值
      this.homeCheck = false // homeCheck=false 页面展示
    }
  },
  methods: {
    filial(data, isConsultation, newPatient = false) { // 接受子组件传来的data
      console.log(data, isConsultation, newPatient = false, '接受子组件传来的data')
      this.newPatient = newPatient
      data.isConsultation = isConsultation // isConsultation标识着是否由会诊tab页进入，放入data中一同传值
      this.chestPain_or_Stroke = data.diseaseType // '胸痛' 或 '卒中'
      this.checkData = data
      this.homeCheck = false
      console.log('传来的数据', data)
    },
    filialBack() { // 从医疗记录页面返回, 不需要返回值, 只需切换页面
      this.homeCheck = true
      // newPatient字段是新增患者返回时刷新页面
      // this.newPatient &&
      // 返回绿道列表刷新
      this.$refs.homePage.init()
      // this.$router.push('/green-channel/patients-list')
    }
  }

}

</script>

<style />
